from django import template

from blog.models import Article, Category


register = template.Library()


@register.simple_tag
def get_recent_article(num=5):
    return Article.objects.all()[:num]


@register.simple_tag
def get_archives():
    return Article.objects.dates('add_time', 'month', order='DESC')


@register.simple_tag
def get_category():
    return Category.objects.all()


